package chess;

import java.util.ArrayList;

public class MSGHolder implements IMSG{
	private String root;
	private ArrayList<IMSG> msgs = new ArrayList<IMSG>();
	public MSGHolder(String root){
		this.root = root;
	}
	public void addMsg(IMSG msg){
		this.msgs.add(msg);
	}
	@Override
	public String toXML() {
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
		sb.append("<"+this.root+">");
		for(int i = 0;i<msgs.size();i++){
			sb.append(msgs.get(i).toXML());
		}
		sb.append("</"+this.root+">");
		return sb.toString();
	}
	
	public int size(){
		return this.msgs.size();
	}
}
